using System;
using Xunit;
using GenericKnowledge;

namespace TestGeneric
{
    public class GenericTest1
    {
        [Fact]
        public void Test1()
        {
            _01StatckT<int> statckInt = new();
            statckInt.Push(100);
            int popValue = statckInt.Pop();
            Assert.Equal(100, popValue);

            
            Assert.Equal(100, statckInt[0]);

            _01StatckT<string> statckString = new();
            statckString.Push("joey dong");
            string popStringValue = statckString.Pop();
            Assert.Equal("joey dong", popStringValue);
        }
        [Fact]
        public void TestGenericMethod()
        {
            _02GenericMethod genericMethodClass = new();
            int a = 100;
            int b = 20;
            genericMethodClass.Swap(ref a, ref b);
            Assert.Equal(20, a);
        }

        [Fact]
        public void TestShelfReferenct()
        {

            _03ShelfReferenceGeneric shelfReferenceGeneric1 = new _03ShelfReferenceGeneric();
            shelfReferenceGeneric1.Name = "joey";
            shelfReferenceGeneric1.Colcor = "red";

            _03ShelfReferenceGeneric shelfReferenceGeneric2 = new _03ShelfReferenceGeneric();
            shelfReferenceGeneric2.Name = "joey";
            shelfReferenceGeneric2.Colcor = "red";

            Assert.Equal(shelfReferenceGeneric1, shelfReferenceGeneric2);



        }

        [Fact]
        public void TestStaticGeneric()
        {
            for (int i = 0; i < 5; i++)
            {
                StaticGeneric<int>.Count++;
            }

            Assert.Equal(5, StaticGeneric<int>.Count);
            //从0重新开始
            for (int i = 0; i < 100; i++)
            {
                StaticGeneric<decimal>.Count++;
            }

            Assert.Equal(100, StaticGeneric<decimal>.Count);
        }
    }



}
